#{extends 'mainSideBar.html' /}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script>
$(function(){
	javascript:getInsideTag();
})
</script>
<script type="text/javascript">
	function getInsideTag() {
		var user = '${userName}';
		var tag = '${tagName}';
		$
				.getJSON(
						'@{BrowseController.showTagContents()}',
						{
							'tagName' : tag,
							'userName' : user
						},
						function(data) {
							var topics = data.topics;
							var ideas = data.ideas;
							var topicsPart = "<h3>Topics</h></br>";
							var ideasPart = "<h3>Ideas</h></br>";
							if (topics == null || topics == "") {
								topicsPart += "No topics to show";
							} else {
								var x = topics.split("&&");
								for ( var i = 0; i < x.length-1; i = i + 1) {
									var id = x[i].split("-")[0];
									var title = x[i].split("-")[1];
									topicsPart += "<a href=\"@{TopicIdeaController.checkAuthorizationToViewTopic()}?topicId=" + id +"\">"+ title + "</a></br>";
								}
							}

							if (ideas == null || ideas == "") {
								ideasPart += "No ideas to show";
							} else {
								var y = ideas.split("&&");

								for ( var j = 0; j < y.length-1; j = j + 1) {
									var id = y[j].split("-")[0];
									var title = y[j].split("-")[1];
									ideasPart += "<a href=\"@{TopicIdeaController.checkAuthorizationToViewIdea()}?ideaId=" + id +"\">" + title + "</a></br>";
								}
							}
							document.getElementById("tagsInfo").innerHTML = topicsPart +  ideasPart;

						});
	}
</script>
</head>
<body>
<div id="tagsInfo"></div>
</body>
</html>